package com.sicheng.lc.周赛.分类.栈.单调栈or单调队列;

import java.util.ArrayDeque;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/2 20:49
 */
public class 使数组按非递减顺序排列 {
    /**
     * https://leetcode.cn/problems/steps-to-make-array-non-decreasing/
     * // todo
     */

    public int totalSteps(int[] nums) {
        ArrayDeque<Integer> deque = new ArrayDeque<>();
        int count = 0;
        for (int num : nums) {
            if (deque.isEmpty() || deque.peekLast() <= num) {
                deque.addLast(num);
            } else {
                count++;
            }
        }

        return count;
    }
}
